package com.aitaoxue.palx.widget;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;

import com.aitaoxue.palx.R;
import com.aitaoxue.palx.util.StringUtils;
import com.nostra13.universalimageloader.core.ImageLoader;

public class AvatarView extends CircleImageView{
	
	private static final String PGIF="portrait.gif";
	private int id;
	private String name;
	
	public AvatarView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init(context);
	}
	
	public AvatarView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}
	
	public AvatarView(Context context) {
		super(context);
		init(context);
	}
	
	private void init(Context context){
		setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				if(!TextUtils.isEmpty(name)){
					
				}
			}
		});
	}
	
	public void setuserInfo(int id,String name){
		this.id=id;
		this.name=name;
	}
	
	public void setAvatarUrl(String url){
		if(url.endsWith(PGIF)||StringUtils.isEmpty(url)){
			setImageResource(R.drawable.widget_dface);
		}else{
			ImageLoader.getInstance().displayImage(url, this);
		}
	}
}




